package com.mobileares.midp.mui.client.form;

import com.google.gwt.user.client.ui.Widget;
import com.mobileares.midp.widgets.client.textbox2.BaseLabelText;
import com.mobileares.midp.widgets.client.textbox2.IFormElementProvider;
import com.mobileares.midp.widgets.client.textbox2.LabelProvider;
import com.wwfish.gwt.model.client.impl.BaseModel;
import com.wwfish.gwt.model.client.mui.BMWidget;
import com.wwfish.gwt.model.client.mui.FishWidget;
import com.wwfish.gwt.reflection.client.ModelReflection;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2011-11-25
 * Time: 8:50:02
 * To change this template use File | Settings | File Templates.
 */
public class BaseLabelTextWrapper<X extends BaseLabelText, T> extends BMWidget<X, T, BaseModel<T>> implements IFormElementProvider {
    protected FishWidget form;
    private String field;
    private Widget ui;

    @Override
    public void ddOutModel() {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    public void setValue(Object object) {
        getBMUI().setValue(ModelReflection.getProperty(object, field));

    }

    public void getValue(Object object) {
        ModelReflection.setProperty(object, field, getBMUI().getValue());
    }

    public void reset(Widget widget) {
        getBMUI().reset();
//        getBMUI().removeErrorMessage();
    }

    BaseLabelTextWrapper(FishWidget form, BaseLabelText widget, String field) {
        this.form = form;
        this.field = field;
        this.ui = widget;
    }
    public X  getBMUI(){
        return (X) ui;
    }

}
